/*
    This file is part of Darwin.

    Darwin is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Foobar is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Foobar; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    
    Darwin uses GALib
    Copyright (c) 1995-1996 Massachusetts Institute of Technology (MIT)
    Copyright (c) 1996-2005 Matthew Wall
    All rights reserved.
    
    Darwin uses ConfigFile
    Copyright (c) 2004 Richard J. Wagner
     
    Darwin, a Genetic Algorithm to solve Timetabling problem
    Copyright (c) 2006 Christian S. Perone
*/  

#if !defined(__TABLEMAPPING_H)
#define __TABLEMAPPING_H

#include "general.h"

#include "options.h"

extern mysqlpp::Connection g_connection;
extern GlobalOptions g_options;

struct ProfessorDisciplinaTable;
struct OferecimentoTable;
struct DisciplinaTable;
struct CursoTable;
struct ProfessorTable;
struct DisponibilidadeTable;
struct DiaSemanaTable;

class MapProfessorDisciplina
{
public:
     MapProfessorDisciplina(bool immediate=false) { if(immediate) LoadData(); };
     ~MapProfessorDisciplina() {};
     
     typedef std::vector<ProfessorDisciplinaTable>::iterator t_iterator;
     typedef std::vector<ProfessorDisciplinaTable> t_vector;

public:
     void LoadData(void);
     t_iterator GetEnd() { return mInsideVector.end(); };
     t_iterator GetBegin() { return mInsideVector.begin(); };
     t_vector& GetVector() { return mInsideVector; };

     
     t_iterator GetInfo(int codprofessordisciplina);
     
protected:
     t_vector mInsideVector;
};

////////////////////////////////////////////////////////////////////////
class MapOferecimento
{
public:
     MapOferecimento(bool immediate=false) { if(immediate) LoadData(); };
     ~MapOferecimento() {};
     
     typedef std::vector<OferecimentoTable>::iterator t_iterator;
     typedef std::vector<OferecimentoTable> t_vector;

public:
     void LoadData(void);
     t_iterator GetEnd() { return mInsideVector.end(); };
     t_iterator GetBegin() { return mInsideVector.begin(); };
     t_vector& GetVector() { return mInsideVector; };
    
     t_iterator GetInfo(int coddisciplina, int nivel);
     
protected:
     t_vector mInsideVector;
};

////////////////////////////////////////////////////////////////////////

class MapDisciplina
{
public:
     MapDisciplina(bool immediate=false) { if(immediate) LoadData(); };
     ~MapDisciplina() {};
     
     typedef std::vector<DisciplinaTable>::iterator t_iterator;

public:
     void LoadData(void);
     t_iterator GetEnd() { return mInsideVector.end(); };
     t_iterator GetBegin() { return mInsideVector.begin(); };
     
     t_iterator GetInfo(int coddisciplina);
     
protected:
     std::vector<DisciplinaTable> mInsideVector;
};

/////////////////////////////////////////////////////////////////////////

class MapCurso
{
public:
     MapCurso(bool immediate=false) { if(immediate) LoadData(); };
     ~MapCurso() {};
     
     typedef std::vector<CursoTable>::iterator t_iterator;
     
public:
     void LoadData(void);
     t_iterator GetEnd() { return mInsideVector.end(); };
     t_iterator GetBegin() { return mInsideVector.begin(); };
     
     t_iterator GetInfo(int codcurso);

protected:
     std::vector<CursoTable> mInsideVector;
};
////////////////////////////////////////////////////////////////////////////
class MapProfessor
{
public:
     MapProfessor(bool immediate=false) { if(immediate) LoadData(); };
     ~MapProfessor() {};
     
     typedef std::vector<ProfessorTable>::iterator t_iterator;
     
public:
     void LoadData(void);
     t_iterator GetEnd() { return mInsideVector.end(); };
     t_iterator GetBegin() { return mInsideVector.begin(); };
     
     t_iterator GetInfo(int codprofessor);

protected:
     std::vector<ProfessorTable> mInsideVector;
};

////////////////////////////////////////////////////////////////////////////
class MapDisponibilidade
{
public:
     MapDisponibilidade(bool immediate=false) { if(immediate) LoadData(); };
     ~MapDisponibilidade() {};
     
     typedef std::vector<DisponibilidadeTable>::iterator t_iterator;
     
public:
     void LoadData(void);
     t_iterator GetEnd() { return mInsideVector.end(); };
     t_iterator GetBegin() { return mInsideVector.begin(); };
     
     t_iterator GetInfo(int codprofessor);

protected:
     std::vector<DisponibilidadeTable> mInsideVector;
};

/////////////////////////////////////////////////////////////////////////////
class MapDiaSemana
{
public:
     MapDiaSemana(bool immediate=false) { if(immediate) LoadData(); };
     ~MapDiaSemana() {};
     
     typedef std::vector<DiaSemanaTable>::iterator t_iterator;
     
public:
     void LoadData(void);
     t_iterator GetEnd() { return mInsideVector.end(); };
     t_iterator GetBegin() { return mInsideVector.begin(); };
     int GetFeriados(int codtimeslot);
     
     t_iterator GetInfo(int coddiasemana);

protected:
     std::vector<DiaSemanaTable> mInsideVector;
};




#endif
